package com.logistics.modules.warehouseManagement.dao;
import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logistics.modules.warehouseManagement.entity.RepositoryEntity;
import org.apache.ibatis.annotations.Param;

import com.logistics.modules.warehouseManagement.entity.SeatEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

/**
 * 
 * 
 * @author HURRICANE
 * @email HURRICANE@nb.com
 * @date 2022-05-07 10:44:16
 */
@Mapper
public interface SeatDao extends BaseMapper<SeatEntity> {

    List<SeatEntity> selectAllByRepositoryId(@Param("repositoryId") Integer repositoryId);

    IPage<SeatEntity> selectAll(@Param("page") IPage<SeatEntity> page,
                                      @Param("storehouse") Integer storehouse,
                                      @Param("seatName") String seatName);

    int deleteByRepositoryIds(@Param("repositoryIds") List<Integer> repositoryIds);

    IPage<SeatEntity> selectAllByStatus(@Param("page") IPage<SeatEntity> page,
                                        @Param("storehouse") Integer storehouse,
                                        @Param("seatName") String seatName);

    SeatEntity selectOneById(@Param("id") Integer id);

    /**
     * 选择一个由货物类型id和存储库id
     *
     * @param cargoTypeId  货物id类型
     * @param repositoryId 库id
     * @return {@link SeatEntity}
     */
    SeatEntity selectOneByCargoTypeIdAndRepositoryId(@Param("cargoTypeId") Integer cargoTypeId, @Param("repositoryId") Integer repositoryId);

    /**
     * 通过id有则更新全部
     *
     * @param seatEntity 座位实体
     * @return int
     */
    int updateSelective(SeatEntity seatEntity);

    /**
     * 统计席位的数量通过仓库id 和 席位能保存的数量
     *
     * @param repositoryId 库id
     * @param cargoTypeId  货物id类型
     * @return int
     */
    int countByRepositoryIdAndCargoTypeId(@Param("repositoryId") Integer repositoryId, @Param("cargoTypeId") Integer cargoTypeId);

    /**
     * 修改席位的状态 通过id
     *
     * @param seatStatus 座位地位
     * @param id         id
     * @return int
     */
    int updateSeatStatusById(@Param("seatStatus") Integer seatStatus, @Param("id") Integer id);

    /**
     * 把货物保存时间重置为空 通过id
     *
     * @param id id
     * @return int
     */
    int updateCargoSaveSeatById(@Param("id") Integer id);

    /**
     * 把货物id重置为空 通过id
     *
     * @param id id
     * @return int
     */
    int updateCargoIdById(@Param("id") Integer id);

    /**
     * 通过仓库id统计席位的数量
     *
     * @param repositoryId 库id
     * @return int
     */
    int countByRepositoryIdAndCargoId(@Param("repositoryId") Integer repositoryId);
}
